#include <iostream>
#include <vector>
#include <queue>

using i64 = long long;

// Topological sorting

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> d(n);
    std::vector adj(n, std::vector<int>());
    for (int i = 0; i < n; ++i) {
        int x;
        while (std::cin >> x && x) {
            --x;
            ++d[x];
            adj[i].push_back(x);
        }
    }

    auto topsort = [&]() {
        std::queue<int> que;
        for (int i = 0; i < n; ++i) {
            if (!d[i]) {
                que.push(i);
            }
        }

        std::vector<int> re;
        while (que.size()) {
            auto t = que.front();
            que.pop();
            re.push_back(t);

            for (auto v : adj[t]) {
                if (--d[v] == 0) {
                    que.push(v);
                }
            }
        }

        return re;
    };
    auto re = topsort();

    for (auto e : re) {
        std::cout << e + 1 << " ";
    }


    return 0;
}
